#ifndef ROBOTCONTROLWIDGET_H
#define ROBOTCONTROLWIDGET_H

#include <QWidget>
#include <QButtonGroup>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QVector>
#include <QLabel>
#include <QScrollArea>
#include <QMap>
#include <QPointer>
#include <QMutex>
#include "jointsliderwidget.h"
#include "customslider.h"
#include "models/command.h"

class RobotControlWidget : public QWidget
{
    Q_OBJECT
public:
    explicit RobotControlWidget(QWidget *parent = nullptr);
    ~RobotControlWidget();
    void setJointCount(JointType tempJointType);

signals:
    void jointValueChanged(int jointId, float value, int mode);

private slots:
    //void onJointBtnClicked(int jointId, bool isLeft);
    void onJointSliderStart(int jointId, float value);
    void onJointSliderStop(int jointId);
    void updateData();
private:
    void initUI();
    void createSlider(QWidget* &tempSliderContainer,CustomSlider* &tempSlider,float fMax,QString strUnit);
    void saveCurrentValues(int mode);
    void restoreValues(int mode);


    CustomSlider * mainSlider;
    CustomSlider * tipSlider1;
    CustomSlider*  tipSlider2;
    QWidget * sliderContainer;
    QWidget * tipSliderContainer;


    QVector<JointSliderWidget*> jointSliders;
    QVBoxLayout * mainLayout;
    QWidget * jointWidget;
    
    QMap<int, QVector<int>> modeValues;
    int currentMode = 0;
    JointType curJointType=HEAD_JOINT;

protected:
    void showEvent(QShowEvent *event);
};

#endif // ROBOTCONTROLWIDGET_H 
